#include "Flag.h"

CFlag::CFlag() : CObjects()
{

}

CFlag::~CFlag()
{

}

CFlag::CFlag(float X, float Y)
{
	reality = 9;
	pos_x = X;
	pos_y = Y;
	width = 8;
	height = 16*8;
	high = pos_y-8*DIS;
}

void CFlag::RenderPieceFlag(int P,float x,float y)
{
	if(P == 1)
		StaticPic->Render(_BackBuffer,x,y,4,3);
	else if(P == 2)
		StaticPic->Render(_BackBuffer,x,y,3,3);
	else if(P == 3)
		StaticPic->Render(_BackBuffer,x,y,2,3);
	else if(P == 4)
		StaticPic->Render(_BackBuffer,x,y,3,2);
}

void CFlag::Die()
{
	if (high<224) high = high+DIS/3;
}

void CFlag::RenderFrame(LPDIRECT3DDEVICE9 d3ddv, int t)
{
	SpriteHandlerSP->Begin(D3DXSPRITE_ALPHABLEND);
	for (int i=0; i<9; i++)
		RenderPieceFlag(1,pos_x,			pos_y-i*DIS);
	RenderPieceFlag(3,pos_x,	pos_y-9*DIS);
	RenderPieceFlag(4,pos_x-DIS,	high);
	RenderPieceFlag(2,pos_x,		high);

}